package com.loobot.album.dao.mapper;
import com.loobot.album.dao.common.CrudMapper;
import com.loobot.album.dao.model.Picture;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author: Ike.Fan
 * @date: 2019/3/1.
 */
@Repository
public interface PictureMapper extends CrudMapper<Picture> {
    @Override
    @Select("SELECT count(*) FROM pictures ")
    int selectCount(Picture picture);

    @Select("SELECT * FROM pictures WHERE album_id =#{albumId}")
    @Results({
            @Result(property = "id", column = "pic_id"),
            @Result(property = "albumId", column = "album_id"),
            @Result(property = "userId",column = "user_id"),
            @Result(property = "picUrl",column = "pic_url"),
            @Result(property = "createTime",column = "create_time"),
            @Result(property = "updateTime",column = "update_time")
    })

    List<Picture> selectByAlbumId(String albumId);
//    @SelectKey(statement = "select uuid()" ,before = true,resultType = Long.class,keyProperty = "id")
//    @Override
//    int insert(Album relation);
}
